/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.commands;

/**
 *
 * @author Developer
 */
public class TravelSetDistance extends CommandBase {
    
    /*
     * Global Class Variables
     */
    private double commandedDistance;
    private boolean bothDisabled = false;
    
    public TravelSetDistance(double distance) {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        
        requires(leftDrivetrain);
        requires(rightDrivetrain);
        commandedDistance = distance;
        
    } // end TravelSetDistance Constructor

    // Called just before this Command runs the first time
    protected void initialize() {
        
        if (leftDrivetrain.areMotorsEnabled() | 
                rightDrivetrain.areMotorsEnabled())
            end();
        
    } // end initialize

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        
        leftDrivetrain.commandDistance(commandedDistance);
        rightDrivetrain.commandDistance(commandedDistance);
        
        if (!leftDrivetrain.areMotorsEnabled() && 
                !rightDrivetrain.areMotorsEnabled())
            bothDisabled = true;
        
    } // end execute

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return bothDisabled;
    } // end isFinished

    // Called once after isFinished returns true
    protected void end() {
    } // end end...lolz

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    } // end interrupted
} // end TravelSetDistance
